<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>添加/编辑网点信息</title>
<#include '/frame/version.html'> 
<#include '/frame/manage/include_css.html'> 
<#include '/frame/manage/include_js.html'> 
<#include '/frame/taglib.html'>
	</head>
	<body id="nv_member">
		<#assign current='menu_org_info'>
		<div id="wp" class="wp">
        <#include "/include/header.html"/>
			<div class="contentmanage">
				<div class="developer">
					<div class="tableContent">
                    <#include "/include/left.html"/> 
                    <#include "/include/wxtop.html"/>
						<div class="content">
							<div class="cLineB">
								<h4 style="font-size:16px;">添加/编辑网点信息</h4>
								<div class="pageNavigator right">
		                			<a class="btnGray" type="button" href="${base}/admin/org/index">返回</a>
		               			</div>
							</div>
							<form method="post" action="${basePath}/admin/org/edit/1" id="mainForm">
								<input name="orgInfoId" value="${bean.orgInfoId}" type="hidden"/>
								<div class="msgWrap">
									<table class="userinfoArea" width="100%">
										<tbody>
											<tr>
												<th valign="top"><span class="red">*</span><label for="input_orgName">机构网点名称：</label></th>
												<td>
													<input type="text" class="px input_width_500" id="input_orgName" value="${bean.orgName}" name="orgName" maxlength="125" placeholder="请输入机构网点名称"/>
												</td>
											</tr>
											<tr>
												 <th valign="top"><span class="red">*</span><label for="input_orgCode">机构网点编号：</label></th>
												<td>
													<input type="text" class="px input_width_500" id="input_orgCode" value="${bean.orgCode}" name="orgCode" maxlength="20" placeholder="请输入机构网点编号"/>
												</td>
											</tr>
											<tr>
												 <th valign="top"><span class="red">*</span><label for="input_pcode">父级机构编码：</label></th>
												<td>
													<input type="text" class="px input_width_500" id="input_pcode" value="${bean.pcode}"  name="pcode" maxlength="20" placeholder="父级机构编码"/>
												</td>
											</tr>
											<tr>
                                                 <th valign="top"><label for="input_phoneNo">SwiftCode：</label></th>
                                                <td>
                                                    <input type="text" class="px input_width_500" id="input_swiftCode" value="${bean.swiftCode}" name="swiftCode" maxlength="15" placeholder="请输入SwiftCode"/>
                                                </td>
                                            </tr>
                                            <tr>
	                                            <th valign="top"><span class="red">*</span>机构级别：</th>
												<td><select id="iput_orgLevel" name="orgLevel" style="width:310px" >
														<option  value="0">--请选择--</option>
														<#if orgLevelSelect?exists && orgLevelSelect != '1'>
															<#if orgLevelSelect==2>
															<option <#if bean.orgLevel=="2">selected</#if> value="2">分行</option>
															<option <#if bean.orgLevel=="3">selected</#if> value="3">支行</option> 
															<#elseif orgLevelSelect==3>
															<option <#if bean.orgLevel=="3">selected</#if> value="3">支行</option>
															</#if>
														<#else>
														<option <#if bean.orgLevel=="1">selected</#if> value="1">总行</option>
														<option <#if bean.orgLevel=="2">selected</#if> value="2">分行</option>
														<option <#if bean.orgLevel=="3">selected</#if> value="3">支行</option> 
														</#if>
												    </select></td>
                                            </tr>
                                            
                                            <tr>
                                               <th valign="top"><span class="red">*</span>所属地区：</th>
												<td>
													<select id="province" name="province" data-value="${bean.province!}" onchange="getCity()" ></select>
													<select id="city" name="city" style="display:none" data-value="${bean.city!}"></select>
												</td>
                                            </tr>
                                            <tr>
                                                <th valign="top"><label for="input_phone">电话：</label></th>
                                                <td>
                                                   <input type="text" class="px input_width_500" id="input_phone" value="${bean.phone}" name="phone" maxlength="15" placeholder="请输入电话"/>
                                                </td>
                                            </tr>
											
											<tr>
                                                <th valign="top"><label for="input_postCode">邮编：</label></th>
                                                <td>
                                                   <input type="text" class="px input_width_500" id="input_postCode" value="${bean.postCode}" name="postCode" maxlength="7" placeholder="请输入邮编"/>
                                                </td>
                                            </tr>
											
											<tr>
                                                <th valign="top"><label for="input_address">地址：</label></th>
                                                <td>
                                                   <input type="text" class="px input_width_500" id="input_address" value="${bean.address}" name="address" maxlength="255" placeholder="请输入地址"/>
                                                </td>
                                            </tr>
                                            
                                            <tr>
                                                <th valign="top"><label for="input_email">邮箱：</label></th>
                                                <td>
                                                   <input type="text" class="px input_width_500" id="input_email" value="${bean.email}" name="email" maxlength="125" placeholder="请输入邮箱"/>
                                                </td>
                                            </tr>
                                            
                                             <tr>
                                                <th valign="top"><label for="input_longitude">经度：</label></th>
                                                <td>
                                                   <input type="text" class="px input_width_500" id="input_longitude" value="${bean.longitude}" name="longitude" maxlength="8" placeholder="请输入纬度"/>
                                                </td>
                                            </tr>
                                            
                                            <tr>
                                                <th valign="top"><label for="input_latitude">纬度：</label></th>
                                                <td>
                                                   <input type="text" class="px input_width_500" id="input_latitude" value="${bean.latitude}" name="latitude" maxlength="8" placeholder="请输入纬度"/>
                                                </td>
                                            </tr>
											
											
											<tr>
												<th></th>
												<td>
													<input type="hidden" name="token" value="${token}" />
													<input type="button" value="保存" class="btnGreen left" id="input_save"/>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
       <#include "/include/footer.html"/>
		<script type="text/javascript">
			$(function(){
				$("#input_save").click(function(){
					var orgName=$.trim($("#input_orgName").val());
					var orgCode=$.trim($("#input_orgCode").val());
					var province=$.trim($("#province").val());
					var city=$.trim($("#city").val());
					var orgLevel=$.trim($("#iput_orgLevel").val());
					var pcode=$.trim($("#input_pcode").val());
					
					if(orgName==""||orgName==null){
						layer.tips("机构网点名称不能为空",$("#input_orgName"))
						return false;
					}
					if(orgCode==""||orgCode==null){
						layer.tips("机构网点编码不能为空",$("#input_orgCode"))
						return false;
					}
					if(province==""&&city==""){
						layer.tips("所属地点不能为空",$("#input_area"))
						return false;
					}
					if(orgLevel=="0"){
						layer.tips("请选择级别",$("#iput_orgLevel"))
						return false;
					}
					if(pcode==null || pcode==""){
						layer.tips("父级机构编码不能为空",$("#input_pcode"))
						return false;
					}
					
					$("#mainForm").submit();
					
				})
				
				getProvince();
			})
		function getProvince(){
			$.ajax({
				type: "GET",
				url: "${basePath}/admin/area/getArea",
				data: {pid:0},
				dataType: "json",
				success: function(data){
					var oldprovince=$("#province").attr("data-value");
					$("#province").empty();
					var opt = $("<option>");
					opt.html("请选择");
					$("#province").append(opt);
					for(var i=0;i<data.length;i++){
						opt = $("<option>");
						opt.val(data[i].id);
						opt.html(data[i].areaname);
						if(oldprovince!=""&&data[i].id==oldprovince){
						    opt.attr("selected", true);
						}
						$("#province").append(opt);
					}
					getCity();
				}
			});
		}
function getCity(){
	var id = $("#province").val();
	$.ajax({
		type: "GET",
		url:"${basePath}/admin/area/getArea",
		data: {pid:id},
		dataType: "json",
		success: function(data){
			if(data==null || data.length==0){
				return;
			}
			var oldcity=$("#city").attr("data-value");
			$("#city").show();
			$("#city").empty();
			var opt = "";
			for(var i=0;i<data.length;i++){
				opt = $("<option>");
				opt.val(data[i].id);
				opt.html(data[i].areaname)
				if(oldcity!=""&&data[i].id==oldcity){
					opt.attr("selected", true);
				}
				$("#city").append(opt)
			}
		}
	});
}

		</script>
	</body>
</html>